from wxpyview.ui.component.common.basewidget import *

class TabGroup(Widget):
    def _getParentParam(self, meta_widget):
        stopping_point = ['Panel']       
        return ComponentLibrary.findFirstMatchedAncestor(meta_widget, stopping_point)
    
    def _setParams(self, meta_widget):
        dom = meta_widget.getDOM()
        if not dom:
            raise IOException
        
        self.params["parent"] = self._getParentParam(meta_widget)
        self.params["id"] = -1
        self.params["pos"] = ComponentLibrary.getPosParam(dom)
        self.params["size"] = ComponentLibrary.getSizeParam(dom)      
        #self.params["style"]
        self.params["name"] = dom.getAttribute("name")
        
    def create(self, meta_widget):
        self._setParams(meta_widget)
        
        o = wx.Notebook(**self.params)
    
        # TODO: BUG: this font setting applies to all children widgets.
        #FontProperty().set(meta_widget, o)
        
        return o